package com.robot.zxlistview;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;

import java.util.ArrayList;
import java.util.List;

public class MainActivity2 extends AppCompatActivity {
    private List<Bean> data = new ArrayList<>();
    final String TAG="MainActivity2>>>>";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        for (int i = 0; i < 100; i++) {
            Bean bean = new Bean();
            bean.setName("享学" + i);
            data.add(bean);
        }
        RecyclerView recyclerView = findViewById(R.id.rv);
        //默认的类似ListView
//        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
//        recyclerView.setLayoutManager(linearLayoutManager);
        //网格布局
//        GridLayoutManager gridLayoutManager = new GridLayoutManager(this,4);
//        recyclerView.setLayoutManager(gridLayoutManager);
        StaggeredGridLayoutManager staggeredGridLayoutManager =
                new StaggeredGridLayoutManager(3, LinearLayout.VERTICAL);
        recyclerView.setLayoutManager(staggeredGridLayoutManager);
        MyAdapter2 myAdapter2 = new MyAdapter2(data, this);
        recyclerView.setAdapter(myAdapter2);
        myAdapter2.setRecyclerItemClickListener(new MyAdapter2.OnRecyclerItemClickListerner() {
            @Override
            public void onRecyClerTtemClick(int position) {
                Log.e(TAG, "onRecyClerTtemClick: "+position );
            }
        });
    }
}